using System.Collections.Generic;
using System.Text.RegularExpressions;

namespace TestCases.CompareAssert.Matchers
{
    internal class RegexEqualityComparer: IEqualityComparer<Regex>
    {
        private static readonly RegexEqualityComparer _instance = new RegexEqualityComparer();

// Explicit static constructor to tell C# compiler not to mark type as beforefieldinit
// ReSharper disable EmptyConstructor
        static RegexEqualityComparer()
// ReSharper restore EmptyConstructor
        {
        }

        private RegexEqualityComparer()
        {
        }

        public static RegexEqualityComparer Instance
        {
            get { return _instance; }
        }        
                    
        public bool Equals(Regex x, Regex y)
        {
            return x.ToString().Equals(y.ToString());
        }

        public int GetHashCode(Regex obj)
        {
            return obj.ToString().GetHashCode();
        }
    }
}